

public class Direction {
	
	public static final int NODIRECTION = 0;
	public static final int NORTH = 1;
	public static final int EAST = 2;
	public static final int SOUTH = 3;
	public static final int WEST = 4;
	
	public static int getDirectionAngle(int robotDirection, int wantedDirection ) {
		
		int directionDiff = -1; //-1 indicates error
		int angleBase = -90;
		
		if (robotDirection == wantedDirection) {
			return 0;
		}
		else {
			directionDiff = robotDirection - wantedDirection;
			
			//if directionDiff is negative it implies clockwise rotation
			//if positive it implies counter clockwise rotation
			if (directionDiff < 0) {
				if (directionDiff == -3)
					directionDiff += 4;
			}
			else {
				if (directionDiff == 3)
					directionDiff -= 4;
			}
			
			return angleBase * directionDiff;
			
		}
		
	}
}
